package main

import (
	"fmt"
	"image"
	"image/color"
	"image/jpeg"
	"math"
	"os"
)

const (
	size = 128
)

func main() {
	paletted := []color.Color{color.White, color.RGBA{255, 0, 0, 0}}
	rec := image.Rect(0, 0, 2*size, 2*size)
	image := image.NewPaletted(rec, paletted)

	for t := 0.0; t < 2*math.Pi; t += 0.001 {
		x := int(2.0*size*t/(2.0*math.Pi) + 0.5)
		y := int(size + 100*math.Sin(t) + 0.5)
		image.SetColorIndex(x, 2*size-y, 1)
	}

	options := jpeg.Options{Quality: 100}
	err := jpeg.Encode(os.Stdout, image, &options)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
	}
}
